#include <stdio.h>
#include <go32.h>
#include <sys/farptr.h>
#include <sys/nearptr.h>

#include <stdlib.h>
#include <time.h>

#include "utypes.h"
#include "music.h"
#include "timer.h"
#include "ints.h"

int main()
{
	timer_init(0,LCOM_MODE);
	timer_init(2,LCOM_MODE);
	
	_go32_dpmi_seginfo old_irq;
	install_asm_irq_handler(T0_IRQ, t0_isr, &old_irq);
	
	Note Si = {Si5, 300};
	Note SOL = {Sol5,300};
	Note MI = {Mi5,300};
	Note FA = {Fa5,300};
	Note OO = {Do5,300};
	Note RE = {Re5,300};
	Note LA = {La5,300};
	
	Note music1[] = { SOL, MI, MI , FA , RE , RE , OO , RE , MI , FA , SOL , SOL , SOL, SOL , MI , MI ,FA , RE , RE , OO , MI , SOL , SOL , OO , RE, RE, RE, RE , RE, RE, MI, FA, MI, MI , MI , MI, MI, FA , SOL, SOL , MI, MI, FA, RE , RE, OO, MI , SOL , SOL  , OO};
	Song s1 = { sizeof(music1)/sizeof(Note), 10, music1};
	
	play_song(&s1);

	Note music2[]= {OO,RE , MI , FA , SOL , SOL , SOL ,LA , SI , OO , LA , SOL , SOL , SOL , FA , SOL , LA , FA , MI , MI, MI , RE , MI , FA , RE , OO ,OO ,OO};

Song s2 = { sizeof(music2)/sizeof(Note), 10, music2};
	
	play_song(&s2);

	Note music3 []= { OO, OO , SOL , SOL , LA , LA , SOL , FA , FA , MI , MI , RE , RE , OO , SOL , SOL , FA , FA , MI , MI , RE , SOL , SOL , FA , FA , MI , MI , RE , OO, OO , SOL , SOL , LA , LA , SOL , FA , FA , MI , MI , RE , RE , OO};

Song s3 = { sizeof(music3)/sizeof(Note), 10, music3};
	
	play_song(&s3);

	
	Note notes[] = {{Do6, 100}, {Re6, 200}, {Mi6, 300}, {Fa6, 400}, {Sol6, 500}, {La6, 500}, {Si6, 500}, {Do7, 500}}; 
	Song s = { sizeof(notes)/sizeof(Note), 10, notes};
 
    play_song(&s);
	
	play_note(&notes[0]);

	reinstall_asm_irq_handler(T0_IRQ, &old_irq);
	
	getchar();
	
	return 0;
}